<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
         .box{
             width: 100px;
             height: 100px;
         }
    
    </style>
</head>
<body>
    <div id="root">
          <div></div>
        <div class="list">
            <div class="item"></div>
            <div class="item"></div>
            <div class="item"></div>
        </div>
        <div class="box">获取验证码</div>
        <div class="abox">获取验证码</div>
    </div>
    <script>
        var str = "wx";
        console.log(typeof str) //string
        console.log([] instanceof Array);
        console.log(String('11') == new String('11'));
        console.log(String('11') === new String('11'));
        var sttr = "a"
                   +"b";
        console.log(sttr);
        var strZ = "你好dd";
        console.log(strZ.length);
        console.log(strZ)
        var dnum = 24;
        var mystr=  "2" + 6 + dnum;  
        console.log(mystr)
        var dstr = "dasdas,你好,我号";
        console.log(dstr.split(','))//吧每一个分成一个数组
        console.log(dstr.split(',',2)) //使用逗号分隔成一个数组@param1:分隔符；@param2：最大长度，如果超出直接舍掉
        console.log('定时器开始')
        var timp = setTimeout(function(){
            console.log('定时器结束')
            clearTimeout(timp)
            console.log(2222)
        },3000);
        
        console.log('定时器已经开始');
        var box = document.getElementsByClassName('box')[0];
        console.log(box)
        var arr = ["red","green","pink"]

        // var btimp = setInterval(function(){
        //     console.log(333)
        //     // var currentColor = box.style.background || "red";
        //     // var currentIndex = arr.indexOf(currentColor);
        //     // if(currentIndex == (arr.length - 1 )){
        //     //     currentIndex = 0;
        //     // }else{
        //     //     currentIndex++;
        //     // }
        //     // box.style.background = arr[currentIndex];

        // },100);
        var t =3;
        var count = null;
        box.onclick = function(){
            getCode(box)
        }
        /**
        *  @desc 获取验证码
        *  @param： ele {DOMSTRING}  节点
        */
        function getCode(ele,ts){
            var t = ts || 60;
            if(ele.innerHTML == "获取验证码"){
                count = setInterval(function(){
                    t--;
                    if(t == 0){
                        ele.innerHTML = "获取验证码";
                        t = ts || 60;
                        clearInterval(count);
                    }else{
                        ele.innerHTML = t+"S";
                    }
                },1000)
            }
        }
    </script>
</body>
</html>